

def data_converse(data):
    converted_data = ''
    if data[0] in ['8','9','a','b','c','d','e','f','A','B','C','D','E','F']:
        b = bin(int(data, 16))[2:]
        # print(b)
        j = 1
        for i in b[1:]:
            if i == '1':
                b = list(b)
                b[j] = '0'
                b = ''.join(b)
            else:
                b = list(b)
                b[j] = '1'
                b = ''.join(b)
            j = j + 1
        # print(b)
        k = len(b) -1
        for i in b[-1:-len(b):-1]:
            if i == '1':
                b = list(b)
                b[k] = '0'
                b = ''.join(b)
            else:
                b = list(b)
                b[k] = '1'
                b = ''.join(b)
                break
            k = k - 1
        if b == '100000000000000000000000':
            converted_data = -int(b,2)
        else:
            converted_data = -int(b[1:], 2)


    else:
        converted_data = int(data, 16)
    # print(converted_data)
    return converted_data * 5000 / (2**26)





if __name__ == '__main__':
    print(data_converse("800000"))
    # str = "55aa012300012e9b000000961b828b170080000080000095feceb0dc5480cf03800000aa"
    # print(len(str))
    # string = "55aa012300012e9b000000961b828b170080000080000095feceb0dc5480cf03800000aa"
    # length = len(string)
    # print(length)
    # data_converse("b55b88")
    # data_converse("b5949f")
    # data_converse("b5a740")
    # data_converse("b5900b")
    # data_converse("b5900b")
    # data_converse("b52e0e")
    # data_converse("b4b765")
    # data_converse("b43b5b")
    # data_converse("b43b5b")
    # 文件路径
    # filename = r"C:\Users\24374\Desktop\test.txt"
    #
    # # 使用with语句确保文件正确关闭
    # with open(filename, 'r', encoding='utf-8') as file:
    #     # 读取所有行到一个列表中
    #     lines = file.readlines()
    #
    # # 去除每行末尾的换行符并创建字符串数组
    # string_array = [line.strip() for line in lines]
    #
    #
    # # 遍历字符串数组
    # for string in string_array:
    #     # 在这里处理每一个字符串
    #     string = string.replace(" ", "")
    #     print(data_converse(string[22:28]))  # 举例：打印每个字符串


